#!/usr/bin/python
# print('hello world')


# def add(a, b):
#     return a + b
#
# print(add(2, 3))
# str1 = 'a'
# print(chr(ord(str1) - 32))
# num = 10
# pi = 3.14159
# str2 = 'test'
# print('num=%d pi=%.2f str2=%s' % (num, pi, str2))
# 练习随机数
# import random
# print(random.randint(1, 100))

# row = 1
# while row <= 5:
#     print('*' * row)
#     row += 1
#
# for i in range(1, 5):
#     print(i,end=' ')
# print(end='\n')
# demo_dict = {"name": "小明"}
# print("定义字典后的内存地址 %d" % id(demo_dict))
# demo_dict["age"] = 18
# demo_dict.pop("name")
# demo_dict["name"] = "老王"
# print("修改数据后的内存地址 %d" % id(demo_dict))

# a = [1, 2, 3, 4, 5]
# b = len(a)
# c = a.index(3)
# print(c)
# print(b)
# info_tuple = ("小明", 21, 1.85)
# # 格式化字符串后面的 `()` 本质上就是元组
# print("%s 年龄是 %d 身高是 %.2f" % info_tuple)
# info_str = "%s 年龄是 %d 身高是 %.2f" % info_tuple
# print(info_str)
# a = [x for x in range(10)]
# print(a)
# b = []
# for x in range(10):
#  b.append(x)
# print(b)
# # 2 个 for 循环
# a = [j for i in range(10) for j in range(i)]
# print(a)
# a = [[col*row for col in range(5)] for row in range(5)]
# print(a)
# a = [j for x in a for j in x] # 2 维列表转 1 维列表
# print(a)
# # 只有 if 时
# print("-"*50)
# a = [x for x in range(10) if x % 2 == 0] # 将只会筛选偶数
# print(a)
# print("-"*50)
# a = [x if x % 2 == 0 else x * 2 for x in range(10)]
# print(a)
# print("-"*50)
# def test():
#     # return {"name": "小明", "age": 21, "height": 1.85}
#     return [1, 2, 3]
# ret = test()
# print(type(ret))
# xiaoming = {}
print("-" * 50)
str1 = "hello world how are you"
print(str1)
str2 = str1.split()
print(str2)
str3 = '  '.join(str2)
print(str3)
print("-" * 50)
# x = {"apple", "banana", "cherry"}
# y = {"google", "runoob", "apple"}
# x.symmetric_difference_update(y)
# print(x, y)
test_list = [1, 2, 3, 4, 5, 6]
test_list[3:3] = ['x', 'y', 'z']
print(test_list)
seasons = ['Spring', 'Summer', 'Fall', 'Winter']
list2 = list(enumerate(seasons))
print(list2)
dict1 = {}
for i in list2:
    dict1[i[1]] = i[0]
print(dict1)
